package com.hnkywl.sts.action.report;

import com.hnkywl.sts.entity.organ.Gsjg;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.service.organ.GsjgService;
import com.hnkywl.sts.service.report.CwsfcService;
import com.hnkywl.sts.service.report.WlycwsfcService;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.util.POIUtil;
import net.ruixin.orm.hibernate.Page;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.DateFormat;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:48
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/report/wlycwsfc")
public class WlycwsfcAction extends SimpleActionSupport {
    private Long gsId;
    private Integer year;
    private Integer month;
    private Date date;
    private int page;
    private int rows;

    private GsjgService gsjgService;
    private WlycwsfcService wlycwsfcService;


    @Action("wlycwsfc")
    public String cwsfc() {
        date = new Date();
        return SUCCESS;
    }

    @Action("wlycwsfcList")
    public void cwsfcList() {
        String json = wlycwsfcService.wlyCwsfcList(gsId, year, month);
        renderJson(json);
    }

    @Action("cbjz")
    public void cbjz() {
        try {
            String errorMsg = wlycwsfcService.cbjz(year, month);
            if (StringUtils.isEmpty(errorMsg))
                renderJson("{\"statusCode\":\"200\", \"message\":\"操作成功!\"}");
            else
                renderJson("{\"statusCode\":\"300\", \"message\":\"" + errorMsg + "\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderJson("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }


    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }



   @Autowired
    public void setGsjgService(GsjgService gsjgService) {
        this.gsjgService = gsjgService;
    }
    @Autowired
    public void setWlycwsfcService(WlycwsfcService wlycwsfcService) {
        this.wlycwsfcService = wlycwsfcService;
    }
}
